﻿@{
    ViewBag.Title = "Quản lý thuộc tính sản phẩm đặc biệt";
    Layout = "~/Areas/Admin/Views/Shared/__AdminLayout.cshtml";
}
@section _Head {
<style type="text/css">

    .field-validation-error
    {
        position: absolute;
        display: block;
    }
    
    * html .field-validation-error { position: relative; }
    *+html .field-validation-error { position: relative; }
    
    .field-validation-error span
    {
        position: absolute;
        white-space: nowrap;
        color: red;
        padding: 17px 5px 3px;
        background: transparent url('@Url.Content("~/Content/Common/validation-error-message.png") ') no-repeat 0 0;
    }
    
    /* in-form editing */
    .t-edit-form-container
    {
        width: 250px;
        margin: 1em;
    }
    
    .t-edit-form-container .editor-label,
    .t-edit-form-container .editor-field
    {
        padding-bottom: 1em;
        float: left;
    }
    
    .t-edit-form-container .editor-label
    {
        width: 30%;
        text-align: right;
        padding-right: 3%;
        clear: left;
    }
    
    .t-edit-form-container .editor-field
    {
        width: 60%;
    }
</style>
    <script type="text/javascript">
        function onEdit(e) {
            $(e.form).find('#IDString').parent().hide();
            $(e.form).find('#IDString').parent().prev().hide();   
            $(e.form).find('#Category').data('tDropDownList').select(function (dataItem) {

                return dataItem.Value == e.dataItem['Category'];
            });
        }
    </script>
} 
<h2>
    Quản lý thuộc tính đặc biệt</h2>
@( Html.Telerik().Grid<Sealight.UI.WebUI.Models.SpecificationAttributeViewModel>()
        .Name("GridProductSpecification")
            .DataKeys(keys =>
            {
                keys.Add(o => o.ID);
            })
            .ToolBar(commands =>
            {
                commands.Insert().ButtonType(GridButtonType.Text).ImageHtmlAttributes(new { style = "margin-left:0" });
            })

            .DataBinding(dataBinding => {
                dataBinding.Ajax().Select("_SpecificationProductSelectAjaxEditing", "Product")
                .Insert("_SpecificationProductInsertAjaxEditing", "Product")
                .Update("_SpecificationProductSaveAjaxEditing", "Product")
                .Delete("_SpecificationProductDeleteAjaxEditing", "Product");
 })
        .Columns(columns =>
        {
            columns.Bound(o => o.ID).Hidden();
            columns.Bound(o => o.Category).Hidden();
            columns.Bound(o => o.Name).Width(200).Title("Tên");
            columns.Bound(o => o.IDString).ClientTemplate("<a href='/admin/product/ManageAttributeOption/<#=IDString#>'>Option</a>").Title("").Width(50);
            columns.Command(commands =>
            {
                commands.Edit().ButtonType(GridButtonType.Text);
                commands.Delete().ButtonType(GridButtonType.Text);
            }).Width(180).Title("");
       
        }).Editable(editing => editing.Mode(GridEditMode.PopUp))
            .Pageable(page => { page.PageSize(20); })
                .ClientEvents(events => events.OnEdit("onEdit"))

)
